/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.LockoutMailboxRequest;
/*    */ import com.zimbra.soap.type.AccountBy;
/*    */ import com.zimbra.soap.type.AccountNameSelector;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class LockoutMailbox
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   protected void checkRights(ZimbraSoapContext lc, Map<String, Object> context, Account account)
/*    */     throws ServiceException
/*    */   {
/* 42 */     Provisioning prov = Provisioning.getInstance();
/* 43 */     Server localServer = prov.getLocalServer();
/* 44 */     checkRight(lc, context, localServer, Rights.Admin.R_moveMailboxFromServer);
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 49 */     ZimbraSoapContext zsc = AdminDocumentHandler.getZimbraSoapContext(context);
/* 50 */     LockoutMailboxRequest req = (LockoutMailboxRequest)JaxbUtil.elementToJaxb(request);
/* 51 */     AccountNameSelector acctSel = req.getAccount();
/* 52 */     if (acctSel == null) {
/* 53 */       throw ServiceException.INVALID_REQUEST(String.format("missing <%s>", new Object[] { "account" }), null);
/*    */     }
/*    */     
/* 56 */     String accountSelectorKey = acctSel.getKey();
/* 57 */     Key.AccountBy by = acctSel.getBy().toKeyAccountBy();
/* 58 */     Provisioning prov = Provisioning.getInstance();
/* 59 */     Account account = prov.get(by, accountSelectorKey, zsc.getAuthToken());
/* 60 */     defendAgainstAccountOrCalendarResourceHarvesting(account, by, accountSelectorKey, zsc, Rights.Admin.R_moveAccountMailbox, Rights.Admin.R_moveCalendarResourceMailbox);
/*    */     
/*    */ 
/*    */ 
/* 64 */     prov.reload(account);
/*    */     
/*    */ 
/* 67 */     checkRights(zsc, context, account);
/*    */     
/* 69 */     String method = request.getAttribute("op", "start");
/*    */     
/* 71 */     if (method.equalsIgnoreCase("start")) {
/* 72 */       MailboxManager.getInstance().lockoutMailbox(account.getId());
/* 73 */     } else if (method.equalsIgnoreCase("end")) {
/* 74 */       MailboxManager.getInstance().undoLockout(account.getId());
/*    */     } else {
/* 76 */       throw ServiceException.FAILURE("Unknown lockout method " + method, null);
/*    */     }
/*    */     
/* 79 */     return zsc.createElement(AdminConstants.LOCKOUT_MAILBOX_RESPONSE);
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 84 */     relatedRights.add(Rights.Admin.R_moveAccountMailbox);
/* 85 */     relatedRights.add(Rights.Admin.R_moveCalendarResourceMailbox);
/* 86 */     relatedRights.add(Rights.Admin.R_moveMailboxFromServer);
/*    */     
/* 88 */     notes.add("If the account is a calendar resource, need " + Rights.Admin.R_moveCalendarResourceMailbox.getName() + " right on the calendar resource.");
/*    */     
/* 90 */     notes.add("If the account is a regular account, need " + Rights.Admin.R_moveAccountMailbox.getName() + " right on the account.");
/*    */     
/* 92 */     notes.add("Need " + Rights.Admin.R_moveMailboxFromServer.getName() + " right on the server");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/LockoutMailbox.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */